package com.qf.service.impl;

import com.qf.entity.Answers;
import com.qf.mapper.AnswersMapper;
import com.qf.service.AnswersService;
import com.qf.service.QuestionsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author ASUS
 * @version V1.0
 * @Project work
 * @Package com.qf.service.impl
 * @Date 2021/10/6 13:58
 */
@Service
public class AnswersServiceImpl implements AnswersService {

    @Autowired
    private AnswersMapper answersMapper;

    @Autowired
    private QuestionsService questionsService;

    @Override
    @Transactional
    public void insert(Answers answer) {
        answersMapper.insertSelective(answer);
        questionsService.update(answer.getQid());
    }

    @Override
    public List<Answers> findAllByQid(long qid) {
        return answersMapper.findAllByQid(qid);
    }
}
